//
//  MarketCell.m
//  陶瓷
//
//  Created by 郭天龙 on 15/7/12.
//  Copyright (c) 2015年 王戈. All rights reserved.
//

#import "MarketCell.h"
#import "MarketModel.h"
#import "UIImageView+WebCache.h"

@interface MarketCell ()

@property (nonatomic, weak) IBOutlet UIImageView *leftTitleImage;
@property (nonatomic, weak) IBOutlet UILabel *leftTitleLabel;
@property (nonatomic, weak) IBOutlet UIImageView *rightTitleImage;
@property (nonatomic, weak) IBOutlet UILabel *rightTitleLabel;

@property (nonatomic, strong) NSArray *arr;

@end

@implementation MarketCell

- (void)awakeFromNib {
    // Initialization code
    self.backgroundColor = [UIColor clearColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void)setModel:(NSArray *)arr
{
    self.arr = [arr mutableCopy];
    MarketModel *model = [self.arr objectAtIndex:0];
    if (self.arr.count > 1) {
        MarketModel *model2 = [self.arr objectAtIndex:1];
        [self.rightTitleImage sd_setImageWithURL:[NSURL URLWithString:model2.ListImageUrl] placeholderImage:nil];
        self.rightTitleLabel.text = model2.Name;
        self.rightTitleLabel.numberOfLines = 0;
    }
    
    [self.leftTitleImage sd_setImageWithURL:[NSURL URLWithString:model.ListImageUrl] placeholderImage:nil];
    self.leftTitleLabel.text = model.Name;
    self.leftTitleLabel.numberOfLines = 0;
}

- (IBAction)clickLeftImageCell:(UITapGestureRecognizer *)sender
{
    if ([self.delegate respondsToSelector:@selector(didMarketCellWithDic:)]) {
        [self.delegate didMarketCellWithDic:[self.arr objectAtIndex:0]];
    }
}

- (IBAction)clickRightImageCell:(UITapGestureRecognizer *)sender
{
    if ([self.delegate respondsToSelector:@selector(didMarketCellWithDic:)]) {
        [self.delegate didMarketCellWithDic:[self.arr objectAtIndex:1]];
    }
}

@end
